package cn.hx.mall.permissions.service.impl;

import cn.hx.mall.permissions.dao.ResourceCategoryDao;
import cn.hx.mall.permissions.entity.ResourceCategory;
import cn.hx.mall.permissions.service.ResourceCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 资源分类表(ResourceCategory)表服务实现类
 *
 * @author makejava
 * @since 2022-11-02 17:02:37
 */
@Service("resourceCategoryService")
public class ResourceCategoryServiceImpl implements ResourceCategoryService {
    @Resource
    private ResourceCategoryDao resourceCategoryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ResourceCategory queryById(Long id) {
        return this.resourceCategoryDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ResourceCategory> queryAllByLimit(int offset, int limit) {
        return this.resourceCategoryDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param resourceCategory 实例对象
     * @return 实例对象
     */
    @Override
    public ResourceCategory insert(ResourceCategory resourceCategory) {
        this.resourceCategoryDao.insert(resourceCategory);
        return resourceCategory;
    }

    /**
     * 修改数据
     *
     * @param resourceCategory 实例对象
     * @return 实例对象
     */
    @Override
    public ResourceCategory update(ResourceCategory resourceCategory) {
        this.resourceCategoryDao.update(resourceCategory);
        return this.queryById(resourceCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.resourceCategoryDao.deleteById(id) > 0;
    }

    @Override
    public List<ResourceCategory> selectAll() {
        return resourceCategoryDao.selectAll();
    }

    @Override
    public List<ResourceCategory> queryAll(ResourceCategory resourceCategory) {
        return resourceCategoryDao.queryAll(resourceCategory);
    }
}